﻿using Dln.Common;
using Dln.Common.Helper;
using Dln.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string Key = "KDNYPYWUMXOW5fEUZ6yUQ1aJx2tgMj5+MgNsqfi6FCcHWsWEAcelgg==";
        string UnicodeKey = Key.Replace("+", "%2B");

        IList<WebServiceData> webServiceDataist = new List<WebServiceData>();
        WebServiceData model = null;

        //昨日入院人数
        object[] arge = new object[1];
        arge[0] = Key;
        var url = CommonHelper.GetAppSettings("DlnService1");
        object getCurrInHospNum = WebServiceHelper.InvokeWebService(url, "GetCurrDayInHospNum", arge);
        if (getCurrInHospNum != null)
        {
            model = new WebServiceData();
            model.ServiceName = "GetCurrDayInHospNum";
            model.ServiceData = getCurrInHospNum.ToString();
            model.SearchDate = DateTime.Now.Date;
            webServiceDataist.Add(model);
        }

        //昨日出院人数
        object getCurrOutHospNum = WebServiceHelper.InvokeWebService(url, "GetCurrOutHospNum", arge);
        if (getCurrOutHospNum != null)
        {
            model = new WebServiceData();
            model.ServiceName = "GetCurrOutHospNum";
            model.ServiceData = getCurrOutHospNum.ToString();
            model.SearchDate = DateTime.Now.Date;
            webServiceDataist.Add(model);
        }

        //昨日退院人数
        object getCurrLeaveHospNum = WebServiceHelper.InvokeWebService(url, "GetCurrLeaveHospNum", arge);
        if (getCurrLeaveHospNum != null)
        {
            model = new WebServiceData();
            model.ServiceName = "GetCurrLeaveHospNum";
            model.ServiceData = getCurrLeaveHospNum.ToString();
            model.SearchDate = DateTime.Now.Date;
            webServiceDataist.Add(model);
        }

        //今日在院退院人数
        object getCurrInHospNums = WebServiceHelper.InvokeWebService(url, "GetCurrInHospNum", arge);
        if (getCurrInHospNums != null)
        {
            model = new WebServiceData();
            model.ServiceName = "GetCurrInHospNum";
            model.ServiceData = getCurrInHospNums.ToString();
            model.SearchDate = DateTime.Now.Date;
            webServiceDataist.Add(model);
        }

        //昨日危重患者人数
        object getCurrCriticallyIllInHospNum = WebServiceHelper.InvokeWebService(url,
            "GetCurrCriticallyIllInHospNum", arge);
        if (getCurrCriticallyIllInHospNum != null)
        {
            model = new WebServiceData();
            model.ServiceName = "GetCurrCriticallyIllInHospNum";
            model.ServiceData = getCurrCriticallyIllInHospNum.ToString();
            model.SearchDate = DateTime.Now.Date;
            webServiceDataist.Add(model);
        }

        //昨日业务收入
        object getYesterdayAmount = WebServiceHelper.InvokeWebService(url, "GetYesterdayAmount", arge);
        if (getYesterdayAmount != null)
        {
            model = new WebServiceData();
            model.ServiceName = "GetYesterdayAmount";
            model.ServiceData = getYesterdayAmount.ToString();
            model.SearchDate = DateTime.Now.Date;
            webServiceDataist.Add(model);
        }

        //昨日门诊人次
        object getYesterdayOutNum = WebServiceHelper.InvokeWebService(url, "GetYesterdayOutNum", arge);
        if (getYesterdayOutNum != null)
        {
            model = new WebServiceData();
            model.ServiceName = "GetYesterdayOutNum";
            model.ServiceData = getYesterdayOutNum.ToString();
            model.SearchDate = DateTime.Now.Date;
            webServiceDataist.Add(model);
        }

        if (webServiceDataist.Count > 0)
        {
            foreach (var item in webServiceDataist)
            {
                var result = SqlHelper.Context.Insert<WebServiceData>(item);
                if (result > 0)
                {
                }
            }
        }
    }
}